<template>
  <a-drawer v-model:visible="LAYER.visible" :title="LAYER.title" :width="LAYER.width"
            :closable="LAYER.closable" :mask-closable="LAYER.maskClosable" :esc-to-close="LAYER.escToClose"
            :unmount-on-close="LAYER.unmountOnClose" :footer="LAYER.footer" :ok-text="LAYER.okText"
            :ok-loading="LAYER.okLoading" :cancel-text="LAYER.cancelText" :on-before-ok="submit" @close="onCancel">
    <!--表单开始-->
    <a-form ref="formRef" :model="data" layout="vertical" :rules="RULES">
      <a-row :gutter="12">
        <a-col :span="12">
          <a-form-item label="审核状态" field="statuss">
            <smart-bool v-model="data.status" true-text="同意" false-text="拒绝"/>
          </a-form-item>
        </a-col>
        <a-col :span="12">
          <a-form-item label="审核说明" field="description">
            <a-input v-model="data.description" allow-clear placeholder="请填写审核说明"/>
          </a-form-item>
        </a-col>
      </a-row>

    </a-form>
    <!--表单结束-->
  </a-drawer>
</template>

<script lang="ts" setup>

import {EditDrawer} from '@/libs/core'
import {APPLY_EDIT} from "../resource/form";
import {ApplyHttp} from '../resource/http'
import {ref} from "vue";

const props = defineProps({record: {type: Object, required: true}})
const emit = defineEmits(['cancel'])
const {BODY, RULES} = APPLY_EDIT

const {updateApply} = ApplyHttp
const config = {tplRecord: BODY, rawRecord: props.record, rowKey: 'id', emit}

const service = new EditDrawer(config).setUpdateRequest(updateApply)
const {formRef, formState, LAYER, isUpdate, onCancel, onSubmit} = service
LAYER.title = isUpdate ? '修改列表' : '新建列表'

const data = ref({
  "status": true,
  "description": ""
})

const submit = () => {
  updateApply(config.rawRecord.id, data.value)
  // onSubmit()
}


</script>
